package cn.huat.controller;

import org.springframework.security.core.Authentication;
import org.springframework.security.core.context.SecurityContextHolder;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;

import java.security.Principal;

/**
 * ClassName: LoginController <br/>
 * Description: <br/>
 * date: 2020/11/25 14:02<br/>
 *
 * @author suhd<br />
 */

@Controller
@RequestMapping("/user")
public class LoginController {

    @RequestMapping("/hello")
    public String login() {
        return "login";
    }

    @RequestMapping("/index")
    public String index(Principal principal) {
        // 获取当前登陆用户账号
        Authentication authentication = SecurityContextHolder.getContext().getAuthentication();
        System.out.println(authentication.getName());
        return "index";
    }

    @RequestMapping("/manager")
    public String toManager(){
        return "systemManager";
    }

    @RequestMapping("/unAuth")
    public String unAuth() {
        return "unauth";
    }
}
